package com.hl.sfzy.controller;


import com.hl.sfzy.entity.SearchArticle;
import com.hl.sfzy.service.SearchArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/search/articles")
public class SearchArticleController {
    @Autowired
    private SearchArticleService searchArticleService;

    @GetMapping("/getArticles")
    public ResponseEntity<Map<String, Object>> searchArticles(@RequestParam String query) {
        List<SearchArticle> articles = searchArticleService.searchArticles(query);

        Map<String, Object> response = new HashMap<>();
        response.put("articles", articles);
        return ResponseEntity.ok(response);

    }
}
